<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2019/11/5
 * Time: 14:08
 */
namespace app\api\service;

use app\common\service\Base as AppBase;

class Base extends AppBase
{
    /**
     * @name 输出错误信息
     * @author wx
     * @date 2020/7/27 14:21
     */
    public function jsonErrOut( $msg = 'error', $code = 202, $data = array())
    {
        $versionPath = './config/serverVersion.conf';
        if (file_exists($versionPath)) {
            $versionPath = file_get_contents($versionPath);
        }

        $outData = [
            'code' => $code,
            'message' => $msg,
            'version' => $versionPath,
        ];

        isset($data['data']) ? $outData = array_merge($outData, $data) : $outData['data'] = $data;

        echo json_encode($outData, JSON_UNESCAPED_UNICODE);die;
    }
}